const app = getApp()
const adapters = require("../../utils/adapters");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    header: {
      title: '我的电池',
      whiteBg: false,
      mode: 'back',
      navBarHeight: app.globalData.navBarHeight,
      tabbarHeight: app.globalData.tabbarHeight,
      screenHeight: app.globalData.screenHeight
    },
    batteryType: [
      {name: '全部'},
      {name: '在保'},
      {name: '过保'},
    ],
    batteryList: [],
  },

  onPageScroll(e) {
    this.setData({
      'header.whiteBg': e.scrollTop < 40 ? false : true
    })
  },
  
  async onLoad(options) {
    const getBatteryListRes = await adapters.getBatteryList()
    if(getBatteryListRes.success) {
      this.setData({
        batteryList: getBatteryListRes.data
      })
    } else {
      wx.showToast({
        title: '数据获取失败！',
        icon: 'none'
      })
    }
  },

})